#include "CVector.h"

CVector::CVector(void)
{
	this->m_x = 0.0f;
	this->m_y = 0.0f;
	this->m_z = 0.0f;
}

CVector::CVector(float _x)
{
	this->m_x = _x;
	this->m_y = 0.0f;
	this->m_z = 0.0f;
}

CVector::CVector(float _x, float _y)
{
	this->m_x = _x;
	this->m_y = _y;
	this->m_z = 0.0f;
}

CVector::CVector(float _x, float _y, float _z)
{
	this->m_x = _x;
	this->m_y = _y;
	this->m_z = _z;
}

bool CVector::SetX(float _x)
{
	this->m_x = _x;
	return true;
}

bool CVector::SetY(float _y)
{
	this->m_y = _y;
	return true;
}

bool CVector::SetZ(float _z)
{
	this->m_z = _z;
	return true;
}

float CVector::GetX(void)
{
	return this->m_x;
}

float CVector::GetY(void)
{
	return this->m_y;
}

float CVector::GetZ(void)
{
	return this->m_z;
}

CVector* CVector::Add(CVector* _vector)
{
	if(_vector != nullptr) return Add(_vector->m_x, _vector->m_y, _vector->m_z);
	else return 0;
}

CVector* CVector::Add(float _x, float _y, float _z)
{
	CVector* pNewVector = new CVector();
	pNewVector->m_x = this->m_x + _x;
	pNewVector->m_y = this->m_y + _y;
	pNewVector->m_z = this->m_z + _z;
	return pNewVector;
}

float CVector::Skalarprodukt(CVector* _vector)
{
	if(_vector != nullptr)	return Skalarprodukt(_vector->m_x, _vector->m_y, _vector->m_z);
	else return 0;
}

float CVector::Skalarprodukt(float _x, float _y, float _z)
{
	return (this->m_x * _x) + (this->m_y * _y) + (this->m_z * _z);
}

CVector* CVector::Kreuzprodukt(CVector* _vector)
{
	if(_vector != nullptr) return Kreuzprodukt(_vector->m_x, _vector->m_y, _vector->m_z);
	else return 0;
}

CVector* CVector::Kreuzprodukt(float _x, float _y, float _z)
{
	CVector* NewVector = new CVector();
	NewVector->m_x = (this->m_y * _z) - (this->m_z * _y);
	NewVector->m_y = (this->m_z * _x) - (this->m_x * _z);
	NewVector->m_z = (this->m_x * _y) - (this->m_y * _x);
	return NewVector;
}

CVector::~CVector(void)
{
	delete this;
}
